package cn.wolfcode.controller;

import cn.wolfcode.domain.Employee;
import cn.wolfcode.enums.RedisKey;
import cn.wolfcode.result.JsonResult;
import cn.wolfcode.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class LoginController {
    @Autowired
    private IEmployeeService employeeService;
    @RequestMapping("/userLogin")
    public Object login(String name,String password){
        Employee employee = employeeService.login(name, password);
        HashMap<String, Object> map = new HashMap<>();
        String token = RedisKey.EMPLOYEE_PERMISSION.getKey(name);
        map.put("token",token);
        map.put("employee",employee);
        return new JsonResult(true,map);
    }
}
